<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增公告信息')" />

</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-notice-edit" th:object="${notice}">
		<div class="form-group">
			<label class="col-sm-3 control-label ">公告标题：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="noticeTitle" th:field="*{noticeTitle}" required>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label">公告类别：</label>
			<div class="col-xs-10">
				<select id="type" class="form-control select2-multiple" multiple>
					<option th:each="type:${tps}" th:value="${type.typeId}" th:text="${type.typeName}" th:disabled="${type.typeId == '1'}"></option>
				</select>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label ">公告内容：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="noticeDesc" th:field="*{noticeDesc}" required>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label ">开始日期：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="startDate"  th:field="*{startDate}" required>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label ">失效日期：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="endDate" th:field="*{endDate}" required>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label ">备注：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="remark" th:field="*{remark}" required>
			</div>
		</div>
	</form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
	function submitHandler() {
		if ($.validate.form()) {
			edit();
		}
	}

	function edit() {
		var noticeTitle = $("input[name='noticeTitle']").val();
		var tId = $.form.selectSelects("typeId");
		var noticeDesc = $("input[name='noticeDesc']").val();
		var startDate = $("input[name='startDate']").val();
		var endDate = $("input[name='endDate']").val();
		var remark = $("input[name='remark']").val();
		$.ajax({
			cache : true,
			type : "POST",
			url : ctx + "notice/cnotice/edit",
			data : {
				"noticeTitle": noticeTitle,
				"tId": tId,
				"noticeDesc": noticeDesc,
				"startDate": startDate,
				"endDate": endDate,
				"remark": remark
			},
			async : false,
			error : function(request) {
				$.modal.alertError("系统错误");
			},
			success : function(data) {
				$.operate.successCallback(data);
			}
		});
	}
</script>
</body>
</html>
